package com.handu.luna.core.domain.promotion;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.handu.luna.core.domain.BaseRepository;

import java.util.List;

public interface TopicRepository extends BaseRepository<Topic>{

	
	@Query("select t from Topic t  order by t.id desc")
    public Page<Topic> findAll(Pageable pageable);

	@Query("select t from Topic  t  where  t.name like %?1 order by t.id desc")
	public Page<Topic> findByName(String name,Pageable pageable);

    @Modifying
    @Query("update Topic t set t.topicModules = ?1 where t.id = ?2")
    public void updateTopicModules(String topicModules,long id);

    @Query("select t from Topic t where t.fileName = ?1")
    public List<Topic> findByFileName(String fileName);
	
    /**
     *-----------------------------------------
     *  @Function 根据专题的文件名称 查询相应的记录
     *  @Params 专题的文件名称
     *  @return Topic 
     *  @author 邹永禹 QQ:3043441459
     *  @date  2014年9月1日 下午1:36:24
     *-----------------------------------------
     */
    @Query("select t from Topic t where t.fileName = ?1")
    public Topic findByFileNameForPortal(String fileName);
    
    
    /**
     * 前端根据专题ID查找  lxx
     * 	
     */
    @Query("from Topic t where t.id = :id")
   // List<Topic> findByTopicId(@Param("id") Long id);
    Topic findByTopicId(@Param("id") Long id);
}
